package online.weiyin.edusys.controller.humanManage;

import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.dev33.satoken.annotation.SaCheckPermission;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import online.weiyin.edusys.common.Result;
import online.weiyin.edusys.entity.dto.response.DepartmentTreeVO;
import online.weiyin.edusys.service.DepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName DeptController
 * @Description 人员管理：组织机构管理
 * @Version 1.0.0
 * @Time 2023/11/07 下午 01:53
 * @Author 卢子昂
 */
@Tag(name = "人员管理：组织机构管理")
@RestController
@SaCheckLogin
@RequestMapping("/api/manages/departments")
public class DepartmentController {
    @Autowired
    private DepartmentService departmentService;

    @Operation(summary = "查询组织列表", description = "[source.basic.show]以嵌套数组的形式获取组织列表")
    @ApiResponse(responseCode = "data", description = "组织列表")
    @SaCheckPermission("source.basic.show")
    @GetMapping("/getDeptList/{deptCode}")
    public Result getDeptList(
            @Parameter(description = "查询的起始组织编码")
            @PathVariable String deptCode) {
        List<DepartmentTreeVO> deptList = departmentService.getDeptList(deptCode);
        return Result.success("查询成功", deptList);
    }
}
